package ase;

import ase.ASE;
import ase.TCPClient;
import dataDAOImpl.MySQLOperatorDAO;
import dataDAOImpl.MySQLProductBatchDAO;
import dataDAOImpl.MySQLProductBatchCompDAO;
import dataDAOImpl.MySQLCommodityBatchDAO;
import dataDAOImpl.MySQLCommodityDAO;
import dataDAOImpl.MySQLRecipeDAO;
import dataDAOImpl.MySQLRecipeCompDAO;
import dataDAOInterfaces.ICommodityBatchDAO;
import dataDAOInterfaces.ICommodityDAO;
import dataDAOInterfaces.IOperatorDAO;
import dataDAOInterfaces.IProductBatchCompDAO;
import dataDAOInterfaces.IProductBatchDAO;
import dataDAOInterfaces.IRecipeCompDAO;
import dataDAOInterfaces.IRecipeDAO;

public class ASEStarter implements Runnable {
	
	private int port;
	private String ip;

	public ASEStarter(String ip, int port)
	{	
		this.ip = ip;
		this.port = port;
	}

	@Override
	public void run() {
		
		Ui ui = new Ui();
		ICommodityDAO comData = new MySQLCommodityDAO();
		ICommodityBatchDAO comBatchData = new MySQLCommodityBatchDAO();
		IOperatorDAO oprData = new MySQLOperatorDAO();
		IProductBatchDAO prodBatchData = new MySQLProductBatchDAO();
		IProductBatchCompDAO prodBatchComp = new MySQLProductBatchCompDAO();
		IRecipeDAO recipeData = new MySQLRecipeDAO();
		IRecipeCompDAO recipeComp= new MySQLRecipeCompDAO();
		
		TCPClient client = new TCPClient(ip, port, ui);
		ASEGets gets = new ASEGets(comData, comBatchData, oprData, prodBatchData, prodBatchComp, recipeData, recipeComp); 
		new Thread(new ASE(ui,client, gets)).start();
		
	}
}
